<?php
namespace Chat\Model;
use Think\Model;
class ChatContributDetailModel extends Model {
	protected $connection = 'DB_BASE_DSN';
	protected $tableName = 'qyx_chat_contribut_detail'; 
	
	
	public function getDetailList($data){
		$map = array();
		if(!empty($data['chatid'])){
			$map['chatid'] = $data['chatid'];
		}
		
		if(!empty($data['contributid'])){
			$map['contributid'] = $data['contributid'];
		}

		
		$total = $this->where($map)->count();
		$fields = array('id','contributid','chatid','custid','amount','status','createtime','updatetime');
		
		$result = $this->field($fields)->where($map)->order("updatetime desc")->select();
		
		return $result;
	}
	
	
	public function getContributDetail($data){
		$map['contributid'] = $data['contributid'];
		$map['custid'] = $data['custid'];
		$result = $this->where($map)->find();
		return $result;
	}
	
	
	public function addContributDetail($data){
		$result = $this->add($data);
		return $result;
	}
	
	
	public function updateContributDetail($data){
		$map['contributid'] = $data['contributid'];
		$map['custid'] = $data['custid'];
		$result = $this->where($map)->save($data);
		return $result;
	}
	
}


